---
#Check TCP Connections
- name: "Check TCP Connections"
  hosts: all
  gather_facts: False
  vars:
    endpoints: "{{ hostvars[inventory_hostname].test.endpoints }}"
  
  tasks:
  - name: "Display tcp connection to be checked"
    debug: 
      msg: "try connection for hostname: {{ item.hostname }} on port: {{ item.port }}"
    with_items:
    - "{{ endpoints }}"
  - name: "Check tcp connection "
    win_check_tcp_endpoint:
      hostname: "{{ item.hostname }}"
      port: "{{ item.port }}"
    with_items:
    - "{{ endpoints }}"
